<?php namespace Home\Controller; 
use Hdphp\Controller\Controller;
/**
 * 订单控制器
 */
class OrderController extends Controller {
	private $model;
	public function __construct()
	{
		//如果没有登陆
		if (!isset($_SESSION['hname'])||!isset($_SESSION['id'])) {
			View::success("没有登陆",'login/index');
		}
		$this->model=new \Common\Model\Order;
	}
	public function index()
	{
		$price=0;
		$data=$this->model->get();
		foreach ($data as $k => $v) {
			$price+=$v['oprice'];
		}
		View::with('price',$price);
		View::with('data',$data);
		View::make();
	}
	public function del()
	{
		$oid=Q('get.oid',0,'intval');
		$listmodel=new \Common\Model\Orderlist;
		$listmodel->where("order_oid={$oid}")->delete();
		$this->model->delete($oid);
		View::success("删除成功",'index');
	}
}
?>